<template>
  <div id="scenic-loglist">
    <el-form :model="scenicLogForm" ref="scenicLogForm" class="scenicLogForm" :inline="true" size="mini">
      <el-form-item label="景区名称">
        <el-input v-model="scenicLogForm.scenicName" placeholder="请输入景区名称"></el-input>
      </el-form-item>
      <el-form-item label="操作时间" class="order-time">
        <el-row>
          <el-col :span="11" class="time-width">
            <el-date-picker
              v-model="scenicLogForm.beginCreateTime"
              type="datetime"
              placeholder="选择开始日期"
              default-time="00:00:00">
            </el-date-picker>
          </el-col>
          <el-col :span="1" class="time-span">~</el-col>
          <el-col :span="11" class="time-width">
            <el-date-picker
              v-model="scenicLogForm.endCreateTime"
              type="datetime"
              placeholder="选择结束日期"
              default-time="23:59:59">
            </el-date-picker>
          </el-col>
        </el-row>
      </el-form-item>
      <el-form-item label="操作人">
        <el-input v-model="scenicLogForm.userName" placeholder="请输入操作人"></el-input>
      </el-form-item>
      <el-button type="primary" size="small" @click="search(1)">搜索</el-button>
    </el-form>

    <el-table
      class="style-a"
      :data="tableData"
      size="small"
      border
      style="width:100%"
      v-loading.body="loadingScenicList" element-loading-text="Loading">
      <el-table-column
        label="景区ID"
        align="center"
        prop="scenicId"
        min-width="120">
      </el-table-column>
      <el-table-column
        label="景区名称"
        align="center"
        prop="scenicName"
        min-width="150">
      </el-table-column>
      <el-table-column
        label="操作时间"
        prop="createTime"
        align="center"
        min-width="140">
      </el-table-column>
      <el-table-column
        label="操作人"
        align="center"
        prop="userName"
        min-width="100">
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        min-width="200">
        <template slot-scope="scope" class="handle">
          <div>
            <p v-html="scope.row.content" class="p-content"></p>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @current-change="handleCurrentChange1"
      :current-page="currentPage"
      :page-sizes="[20]"
      :page-size="20"
      layout="total, prev, pager, next, jumper"
      :total="totalSize">
    </el-pagination>
  </div>
</template>
<script>
  import { mapGetters } from 'vuex'
  import { getScenicRecords } from '@/api/scenicLogList'
  export default {
    computed: {
      ...mapGetters([
        'name',
        'roles'
      ])
    },
    data() {
      return {
        scenicLogForm: {
          scenicName: null,
          userName: null,
          beginCreateTime: null,
          endCreateTime: null
        },
        currentPage: 1,
        totalSize: null,
        tableData: [],
        loadingScenicList: false,
        takeOffDialogVisible: false
      }
    },
    created() {
      this.getScenicList()
    },
    methods: {
      search() {
        this.currentPage = 1
        this.getScenicList()
      },
      handleCurrentChange1(val) {
        this.currentPage = val
        this.getScenicList(val)
      },
      getScenicList() {
        this.loadingScenicList = true
        let params = {
          beginCreateTime: new Date(this.scenicLogForm.beginCreateTime).getTime() || null,
          endCreateTime: new Date(this.scenicLogForm.endCreateTime).getTime() || null,
          pageNumber: this.currentPage,
          pageSize: 20,
          scenicName: this.scenicLogForm.scenicName || null,
          userName: this.scenicLogForm.userName || null
        }
        getScenicRecords(params).then(res => {
          let data = res.data
          this.loadingScenicList = false
          if (data.errorCode === 'E_000') {
            this.tableData = data.body.list
            this.totalSize = data.body.total
          }
        }).catch(() => {
          this.loadingScenicList = false
        })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss">
  #scenic-loglist{
     .p-content{
       text-align: left;
     }
  }
</style>
